Skip to content

Conversation

@zachcran
Copy link
Contributor

@zachcran zachcran commented May 12, 2025

Description

CMaize uses find_package() in Config search mode to detect an installed version of a dependency. find_package in this mode looks for files named <PackageName>Config.cmake (case sensitive) or <lowercasePackageName>-config.cmake (also case sensitive, but lowercase). CMaize, by default, uses the dependency name provided to cmaize_find_or_build_dependency, which is eigen, but the Eigen package generates this file as Eigen3Config.cmake.

Solution

Use the optional NAME field in cmaize_find_or_build_dependency to set the correct find_package name to Eigen3.

Required for NWChemEx/TensorWrapper#212.

TODOs

  • Verify that this solution works with an installed version of Eigen (through Spack for me).
  • Verify that this solution works when building Eigen from source on my system (Linux, GCC 14.2.1).

@zachcran
Copy link
Contributor Author

zachcran commented May 12, 2025

@jwaldrop107 Technically, the Spack build still does not work, even with this fix. However, it is an internal issue to CMaize that needs to be fixed, so I don't think it is necessary as part of this PR. Therefore, I'd say this PR is r2g.

Here is the explanation of the issue:

cmaize_find_or_build_optional_dependency() calls target_compile_definitions() on the target (L43) after it finds the target, which results in the following error when Eigen was not built as part of the sigma build:

-- Attempting to find installed eigen
Looking for eigen
Creating a Git dependency
Was already found? FALSE
-- eigen installation found
CMake Error at /tmp/zachcran/spack-stage/spack-stage-sigma-master-lntoxru2oivacwbpl3rwcj3jlqi2yjg3/spack-build-lntoxru/_deps/cmaize-src/cmake/cmaize/user_api/dependencies/find_or_build_optional_dependency.cmake:42 (target_compile_definitions):
  Cannot specify compile definitions for target "eigen" which is not built by
  this project.

A workaround can also be applied in sigma by using cmaize_find_or_build_dependency() and wrapping the call with an if("${ENABLE_EIGEN_SUPPORT}"), if you want a fix faster.

NOTE: I have duplicated this explanation to an issue (#25) to better track it.

@jwaldrop107
Copy link
Contributor

@zachcran I would say we go ahead and merge this, working under the assumption that you'll have the CMaize fix in place shortly. If that fix starts to drag out, the workaround you proposed can be added in a separate PR.

@jwaldrop107 jwaldrop107 merged commit 50b85ea into QCUncertainty:main May 12, 2025
11 checks passed
@zachcran zachcran deleted the patch-1 branch June 12, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants